package icu.xuyijie.springbootlearning2.chapter4.file;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * @author 徐一杰
 * @date 2025/03/03 15:33
 * @description 文件相关操作
 */
@RestController
@RequestMapping("/file")
public class FileController {

    @PostMapping("/upload")
    public void uploadFile(MultipartFile multipartFile) throws IOException {
        // 构建文件的保存路径
        String fileName = "D:\\下载\\" + multipartFile.getOriginalFilename();
        // 保存
        multipartFile.transferTo(new File(fileName));
    }

}
